package cn.zxh.improvement.common.core.pipeline.selector;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;


/**
 * 本地列表基本查找器
 *
 * @author zxh
 * @since 2023-6-7 16:12:23
 */
public class LocalListBasedFilterSelector implements FilterSelector {

    public LocalListBasedFilterSelector() {
    }

    private List<String> filterNames = new ArrayList<>();

    @Override
    public boolean matchFilter(String classSimpleName) {
        return this.filterNames.stream().anyMatch(s -> Objects.equals(s, classSimpleName));
    }

    @Override
    public List<String> getFilterNames() {
        return this.filterNames;
    }

    public void addFilter(String clsNames) {
        this.filterNames.add(clsNames);
    }

    public void addFilters(List<String> filterNames) {
        this.filterNames.addAll(filterNames);
    }

    public LocalListBasedFilterSelector(List<String> filterNames) {
        this.filterNames = filterNames;
    }
}
